package com.koro.controller;


import com.koro.dto.SaveShopCartDTO;
import com.koro.service.ShopCartService;
import com.koro.vo.FindShopCartVO;
import com.koro.vo.ResponseObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "购物车管理")
@RequestMapping("/shopChart")
@RestController
public class ShopCartController {

    @Autowired
    private ShopCartService shopCartService;

    @ApiOperation(value = "添加购物车",notes = "添加购物车")
    @PostMapping("/save")
    public ResponseObject<Integer> save(@RequestBody SaveShopCartDTO dto) {
        return ResponseObject.ok(shopCartService.save(dto));
    }

    @ApiOperation(value = "查询购物车",notes = "查询购物车")
    @PostMapping("/findByUsersId")
    public ResponseObject<List<FindShopCartVO>> findByUsersId(@RequestParam Integer id) {
        return ResponseObject.ok(shopCartService.findByUsersId(id));
    }
}
